<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>

        main {
            background: greenyellow;
            height: 300px;
            margin: 20px;
            width: 300px;
            position: relative;

            border: 2px solid black;

            resize: vertical;
            overflow: auto;

            transform-style: preserve-3d;
        }

        main div {
            position: absolute;
            top: 50%;
            left: 20px;
            right: 20px;
            background: black;
            color: white;
            padding: 20px;
            transform: translateY(-50%);
            resize: vertical;
            overflow: auto;
        }
    </style>

    <style>

    </style>
</head>
<body>
<main>

    <div>
        测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试
    </div>

</main>
</body>
</html>